<!doctype html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Tendências de Faturamento - Previsão Manual</title>
    
    <style type="text/css">
      .moeda{
      	width: 65px;
      }
    </style>
    
	<%@ include file="head.jsp" %>	
    <script type="text/javascript" src="resources/js/moeda.js"></script>
        
   		<script type="text/javascript">
		  var _gaq = _gaq || [];
		  _gaq.push(['_setAccount', 'UA-35513738-1']);
		  _gaq.push(['_trackPageview']);
		
		  (function() {
		    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		  })();
		
		</script>		
        
  </head>

  <body>
	<%@ include file="menu.jsp" %>
    
    <div class="container-fluid">
		<div class="row-fluid">
		
			<div class="page-header"><h1>Metas de Faturamento</h1></div>
  			
  			<c:if test="${mensagemSucesso != null}">
				<div class="alert alert-info" style="text-align: center;">${mensagemSucesso}</div>  			
  			</c:if>
  			
  			<form:form method="post" action="previsao" modelAttribute="faturamentoAnualForm">
  		
			<label style="display: inline;">Entidade:</label>
			<form:select path="idEntidade" items="${entidades}" itemLabel="nome" itemValue="id" onchange="window.location.href='previsao/'+this.value;" />
  			
			<br/><br/>
			  
			<table>
				<thead>
					<tr>
						<th>Ano</th>
						<th>Janeiro</th>
						<th>Fevereiro</th>
						<th>Março</th>
						<th>Abril</th>
						<th>Maio</th>
						<th>Junho</th>
						<th>Julho</th>
						<th>Agosto</th>
						<th>Setembro</th>
						<th>Outubro</th>
						<th>Novembro</th>
						<th>Dezembro</th>
					</tr>
				</thead> 
				<tbody>
					<c:forEach items="${faturamentoAnualForm.faturamentosAnuais}" var="fatAnual" varStatus="status">
						<tr>
							<th>${fatAnual.ano}
								<input type="hidden" name="faturamentosAnuais[${status.index}].ano" value="${fatAnual.ano}" />
							</th>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 0 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].janeiro" value="${fatAnual.janeiro}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 1 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].fevereiro" value="${fatAnual.fevereiro}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 2 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].marco" value="${fatAnual.marco}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 3 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].abril" value="${fatAnual.abril}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 4 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].maio" value="${fatAnual.maio}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 5 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].junho" value="${fatAnual.junho}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 6 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].julho" value="${fatAnual.julho}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 7 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].agosto" value="${fatAnual.agosto}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 8 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].setembro" value="${fatAnual.setembro}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 9 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].outubro" value="${fatAnual.outubro}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 10 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].novembro" value="${fatAnual.novembro}" class="moeda" /></td>
							<td><input type="text" maxlength="16" onkeypress="reais(this,event)" onkeydown="backspace(this,event)" <c:if test="${fatAnual.ano <= anoAtual && 11 < mesAtual}">disabled="disabled"</c:if> name="faturamentosAnuais[${status.index}].dezembro" value="${fatAnual.dezembro}" class="moeda" /></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<br/>
			<input type="submit" class="btn btn-primary btn-large" value="Salvar" />

			</form:form>
			
			<%@ include file="rodape.jsp" %>
		</div>
    </div>
  </body>
</html>  